package com.lnsf.bookstore.system.cart.vo;

import com.lnsf.bookstore.system.book.vo.Book;
import com.lnsf.bookstore.system.vipuser.vo.VipUser;

import java.io.Serializable;
import java.math.BigDecimal;

public class Cart implements Serializable {
    /**
     * 购物车id
     */
    private Integer id;

    /**
     * 用户id
     */
    private Integer userId;

    /**
     * 书籍Id
     */
    private Integer bookId;

    /**
     * 数量
     */
    private Integer number;

    /**
     * 价格
     */
    private BigDecimal price;

    private VipUser vipUser;

    private Book book;

    public String getUserName(){
        if(getVipUser()!=null){
            return getVipUser().getUsername();
        }
        return "--";
    }

    public String getBookName(){
        if(getBook()!=null){
            return getBook().getName();
        }
        return "--";
    }

    public BigDecimal getUnitPrice(){
        if(getBook()!=null){
            return getBook().getUnitPrice();
        }
        return new BigDecimal(0);
    }


    /**
     * bs_cart
     */
    private static final long serialVersionUID = 1L;

    /**
     * 购物车id
     * @return id 购物车id
     */
    public Integer getId() {
        return id;
    }

    /**
     * 购物车id
     * @param id 购物车id
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     * 用户id
     * @return userId 用户id
     */
    public Integer getUserId() {
        return userId;
    }

    /**
     * 用户id
     * @param userId 用户id
     */
    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    /**
     * 书籍Id
     * @return bookId 书籍Id
     */
    public Integer getBookId() {
        return bookId;
    }

    /**
     * 书籍Id
     * @param bookId 书籍Id
     */
    public void setBookId(Integer bookId) {
        this.bookId = bookId;
    }

    /**
     * 数量
     * @return number 数量
     */
    public Integer getNumber() {
        return number;
    }

    /**
     * 数量
     * @param number 数量
     */
    public void setNumber(Integer number) {
        this.number = number;
    }

    /**
     * 价格
     * @return price 价格
     */
    public BigDecimal getPrice() {
        return price;
    }

    /**
     * 价格
     * @param price 价格
     */
    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public VipUser getVipUser() {
        return vipUser;
    }

    public void setVipUser(VipUser vipUser) {
        this.vipUser = vipUser;
    }

    public Book getBook() {
        return book;
    }

    public void setBook(Book book) {
        this.book = book;
    }
}